package com.edu.framework.websocket.handler;

import com.edu.framework.websocket.WebSocketHolder;
import com.edu.framework.websocket.message.base.Response;
import com.edu.framework.websocket.message.card.CardInfoVO;
import com.edu.framework.websocket.message.card.CardListRequest;
import com.edu.framework.websocket.message.card.CardRequest;
import com.edu.framework.websocket.service.CardService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

@Component
public class CardListRequestHandler implements IHandler<CardListRequest> {

    @Resource
    private CardService wsCardService;

    @Override
    public void execute(WebSocketSession session, CardListRequest message) {
        if (message == null) {
            return;
        }
        Map<String, String> data = message.getData();

        Response<List<CardInfoVO>> response = wsCardService.cardList(new ArrayList<>());

        try {
            WebSocketHolder.send(session,response);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public String getType() {
        return CardListRequest.TYPE;
    }




}
